<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <style>
        .wrap {
            margin: 10px;
        }

        .list {
            margin-top: 10px;
            line-height: 40px;
            text-indent: 10px;
        }

        .list li {
            border: 1px dashed #333;
        }

        .list li+li {
            border-top: 0;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <button>删除元素</button>
        <ul class="list">
            <li class="first">01</li>
            <li>02</li>
            <li class="mid">03</li>
            <li>04</li>
            <li>05</li>
            <li class="last">06</li>
        </ul>
    </div>
</body>
<script>


    // 点击 删除元素 按钮 => 创建一个li放到list中

    var btn = document.getElementsByTagName("button")[0];
    var ul = document.getElementsByClassName("list")[0];
    var mid = document.getElementsByClassName("mid")[0];


    // 自删  
    // Element.remove() 

    // 父删  => 父元素统筹
    // parent.removeChild(node)

    btn.onclick = function () {
        // if (mid) {
        //     mid.remove();
        //     mid = null;
        // }


        if (mid) {
            ul.removeChild(mid);
            mid = null;
        }
    }






</script>

</html>